<HTML>
<HEAD>
<TITLE>An Example of Formatting Phone Numbers</TITLE>
<LINK REL=StyleSheet HREF="../rw.css" TYPE="text/css" TITLE="Rogue Wave Standard Stylesheet"></HEAD>
<BODY BGCOLOR=#FFFFFF>
<A HREF="26.html"><IMG SRC="images/bprev.gif" WIDTH=20 HEIGHT=21 ALT="Previous file" BORDER=O></A><A HREF="noframes.html"><IMG SRC="images/btop.gif" WIDTH=56 HEIGHT=21 ALT="Top of Document" BORDER=O></A><A HREF="booktoc.html"><IMG SRC="images/btoc.gif" WIDTH=56 HEIGHT=21 ALT="Contents" BORDER=O></A><A HREF="tindex.html"><IMG SRC="images/bindex.gif" WIDTH=56 HEIGHT=21 ALT="Index page" BORDER=O></A><A HREF="26-2.html"><IMG SRC="images/bnext.gif" WIDTH=25 HEIGHT=21 ALT="Next file" BORDER=O></A><DIV CLASS="DOCUMENTNAME"><B>Rogue Wave C++ Standard Library User's Guide</B></DIV>
<H2>26.1 An Example of Formatting Phone Numbers</H2>
<A NAME="idx585"><!></A>
<A NAME="idx586"><!></A>
<P>The previous chapters explained how you can use locales and the standard facet classes, and how you can build new facet classes. This chapter introduces you to the technique of building your own facet class and using it in conjunction with the input/output streams of the Standard C++ Library, the iostreams. This material is rather advanced, and requires some knowledge of standard iostreams.</P>
<A NAME="idx587"><!></A>
<P>In the following sections, we will work through a complete example on formatting telephone numbers. Formatting telephone numbers involves local conventions that vary from culture to culture. For example, the same US phone number can have all of the formats listed below:</P>
<TABLE BORDER="0" CELLPADDING="3" CELLSPACING="3">
<tr><td valign=top><P CLASS="TABLE">754-3010</P>
</td><td valign=top><P CLASS="TABLE">Local</P>
</td></tr>
<tr><td valign=top><P CLASS="TABLE">(541) 754-3010</P>
</td><td valign=top><P CLASS="TABLE">Domestic</P>
</td></tr>
<tr><td valign=top><P CLASS="TABLE">+1-541-754-3010</P>
</td><td valign=top><P CLASS="TABLE">International</P>
</td></tr>
<tr><td valign=top><P CLASS="TABLE">1-541-754-3010</P>
</td><td valign=top><P CLASS="TABLE">Dialed in the US</P>
</td></tr>
<tr><td valign=top><P CLASS="TABLE">001-541-754-3010</P>
</td><td valign=top><P CLASS="TABLE">Dialed from Germany</P>
</td></tr>
<tr><td valign=top><P CLASS="TABLE">191 541 754 3010</P>
</td><td valign=top><P CLASS="TABLE">Dialed from France</P>
</td></tr>
</TABLE>
<P>Now consider a German phone number. Although a German phone number consists of an area code and an extension like a US number, the format is different. Here is the same German phone number in a variety of formats:</P>
<TABLE BORDER="0" CELLPADDING="3" CELLSPACING="3">
<tr><td valign=top><P CLASS="TABLE">636-48018</P>
</td><td valign=top><P CLASS="TABLE">Local</P>
</td></tr>
<tr><td valign=top><P CLASS="TABLE">(089) / 636-48018</P>
</td><td valign=top><P CLASS="TABLE">Domestic</P>
</td></tr>
<tr><td valign=top><P CLASS="TABLE">+49-89-636-48018</P>
</td><td valign=top><P CLASS="TABLE">International</P>
</td></tr>
<tr><td valign=top><P CLASS="TABLE">19-49-89-636-48018</P>
</td><td valign=top><P CLASS="TABLE">Dialed from France</P>
</td></tr>
</TABLE>
<P>Note the difference in formatting domestic numbers. In the US, the convention is <SAMP>1 (area code) extension</SAMP>, while in Germany it is <SAMP>(0 area code)/extension</SAMP>.</P>

<BR>
<HR>
<A HREF="26.html"><IMG SRC="images/bprev.gif" WIDTH=20 HEIGHT=21 ALT="Previous file" BORDER=O></A><A HREF="noframes.html"><IMG SRC="images/btop.gif" WIDTH=56 HEIGHT=21 ALT="Top of Document" BORDER=O></A><A HREF="booktoc.html"><IMG SRC="images/btoc.gif" WIDTH=56 HEIGHT=21 ALT="Contents" BORDER=O></A><A HREF="tindex.html"><IMG SRC="images/bindex.gif" WIDTH=56 HEIGHT=21 ALT="Index page" BORDER=O></A><A HREF="26-2.html"><IMG SRC="images/bnext.gif" WIDTH=20 HEIGHT=21 ALT="Next file" BORDER=O></A></BODY>
</HTML>
